﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using DotNetNuke.Entities.Modules;
using iFinity.DNN.Modules.BlogFriendlyUrlProvider.Entities;

namespace iFinity.DNN.Modules.BlogFriendlyUrlProvider.Data
{
    internal abstract class DataProvider
    {
        #region Shared/Static Methods

        // singleton reference to the instantiated object 
        static DataProvider objProvider = null;

        // constructor
        static DataProvider()
        {
            CreateProvider();
        }

        // dynamically create provider
        private static void CreateProvider()
        {
            //don't need run-time instancing when using built-in sqlDataProvider class
            //objProvider = ((DataProvider)DotNetNuke.Framework.Reflection.CreateObject("data", "iFinity.DNN.Modules.ForumFriendlyUrlProvider.Data", "iFinity.DNN.Modules.ForumFriendlyUrlProvider"));
            objProvider = new Data.SqlDataProvider();
        }

        // return the provider
        public static DataProvider Instance()
        {
            return objProvider;
        }

        #endregion

        #region abstract methods
        /// <summary>
        /// Returns a list of entries and list of blogs that can be found on a given page
        /// </summary>
        /// <param name="tabId">The tabid we are looking for blog entries on.</param>
        /// <param name="cultureCode">Culture of specific entries to retrieve</param>
        /// <param name="startingItemId">The item that the friendly urls should start from</param>
        /// <param name="entries">out parameter returns a zero-n list of blog entries</param>
        /// <param name="blogs">out parameter reutns a zero-n list of blogs</param>
        internal abstract void GetBlogEntriesForTab(int tabId,string cultureCode, int startingItemId, out BlogEntryInfoCol entries, out BlogInfoCol blogs, out CategoryInfoCol cats, out TagInfoCol tags, out bool isBlog6);
        internal abstract Dictionary<int, BlogInfo> GetBlogsForPortal(int portalId);
        internal abstract BlogEntryInfo GetBlogEntry(int itemId,string cultureCode);
        #endregion
    }
}
